#include <bits/stdc++.h>
using namespace std;
int main()
{
    string pk;
    vector<int> vec(26, 0);
    vector<int> flag(26, 0);
    int count = 0;
    int maxscore = 0;
    while (getline(cin, pk))
    {
        count++;
        int idx1 = pk[0] - 'a';
        int idx2 = pk[2] - 'a';
        flag[idx1] = 1;
        flag[idx2] = 1;
        int tmpidx = 4;
        string sco = "";
        while (isdigit(pk[tmpidx]))
        {
            sco += pk[tmpidx];
            tmpidx++;
        }
        tmpidx++;
        int score1 = stoi(sco);
        sco = "";
        while (tmpidx < pk.length() && isdigit(pk[tmpidx]))
        {
            sco += pk[tmpidx];
            tmpidx++;
        }
        int score2 = stoi(sco);
        if (score1 > score2)
            vec[idx1] += 3;
        else if (score1 == score2)
        {
            vec[idx1]++;
            vec[idx2]++;
        }
        else
            vec[idx2] += 3;
        if (maxscore < vec[idx1])
            maxscore = vec[idx1];
        if (maxscore < vec[idx2])
            maxscore = vec[idx2];
    }
    int team = 0;
    for (int i = 0; i < 26; i++)
    {
        if (flag[i] == 1)
        {
            team++;
        }
    }
    for (int i = maxscore; i >= 0; i--)
    {
        for (int j = 0; j < 26; j++)
        {
            if (flag[j] == 1 && i == vec[j])
            {
                cout << (char)('a' + j) << " " << i;
                vec[j] = 0;
                flag[j] = 0;
                team--;
                if (team >= 1)
                {
                    cout << ",";
                }
                else
                    cout << endl;
            }
        }
    }
}
